import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";

//vue中引用
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'




const app = createApp(App);

app.use(store).use(router).use(ElementPlus);

/*路由的前置守卫*/
// 创建不需要token的白名单
const whileList = ["/"];
// 如果在白名单或者有token就允许跳转
router.beforeEach((to, from, next) => {
  if (whileList.includes(to.path) || localStorage.getItem("token")) {
    next();
  } else {
    /*否则就跳转回登录页*/
    next("/");
  }
});
app.mount("#app");
